#ifndef EFFECTWIDGET_H
#define EFFECTWIDGET_H
#include <widget.h>
#include <QList>
#include <QTimer>
#include <effectanimation.h>

enum ANIMATION {
    IN,
    OUT
};

enum DIRECTION{
    LEFT_BORDER,
    RIGHT_BORDER
};

class EffectWidgetAnimation : public QObject, public EffectAnimation
{
    Q_OBJECT
public:
    EffectWidgetAnimation(QWidget* parent, DIRECTION dir=LEFT_BORDER);

    /**
     * @brief addButton     添加按钮
     * @param widget
     */
    void addButton(QPushButton* widget);

    /**
     * @brief removeButton  删除一个button
     * @param widget
     */
    void removeButton(QPushButton *widget);
    void removeButton(const QString& title);

    /**
     * @brief setStyleSheets        设置风格
     * @param style
     */
    void setStyleSheets(const QString& style);

    /**
     * @brief getDuration       动画时间
     */
    unsigned getDuration() const;
    void setDuration(const unsigned &value);

    void setInitialze(const ANIMATION& action);


    int getWidth() const;
    void setWidth(int value);

    int getHeight() const;
    void setHeight(int value);

    int getGap() const;
    void setGap(int value);

    int getInterval() const;
    void setInterval(int value);

    DIRECTION getDirtion() const;

    /**
     * @brief setDirtion        设置方向
     * @param value
     */
    void setDirtion(const DIRECTION &value);

    ANIMATION getCurrentStatus() const;

    /**
     * @brief getAllButton      获取所有的button
     * @return
     */
    QList<QPushButton *> getAllButton() const;

public slots:
    /**
     * @brief anmation      属性动画
     * @param action
     */
    void animationStart( ANIMATION action=IN);    

private slots:
    void timeoutSlotOut();
    void timeoutSlotIn();

    void btnClickedSlot();

protected:
    void signalDeal();
private:
    /**
     * @brief init      初始化
     */
    void initStatus();

    void setButtonUnchecked();

    void sizeReset();
    QWidget* parent;

    QList<QPushButton*> allButton;      //保存所有的button
    QList<QRect> allRect;

    unsigned duration;      //动画时间
    int width;
    int height;
    int gap;
    int interval;
    QTimer * timer;
    DIRECTION dirtion;  //方向
    Widget * widget;    //保存自己的widget
    ANIMATION currentStatus;  //当前状态

    int x;  //x坐标
};

#endif // EFFECTWIDGET_H
